<template>
  <footer>
    <div v-for="(l, i) in footList" :key="i">
      <router-link @click.native="format(l,i)" to=" ">
        <i class="iconfont" :class="l.icon" :style="activeBtn==i?'color:#000':'#fff'"></i>
        <span :style="activeBtn==i?'color:#000':'#fff'">{{ l.text }}</span>
      </router-link>
    </div>
  </footer>
</template>


<script>
import { footList } from "@/utils";
export default {
  props: ["back"],
  data() {
    return {
      footList,
      activeBtn:0,//默认选中当前第一个
    };
  },
  computed: {},
  methods: {
    format(l,i){
      console.log("获取i的值",i)
      this.activeBtn=i;
      if(i==2){//购物车
        if(localStorage.getItem("phone")){
              this.$router.push({
                name:l.name
              })
        }else{
            this.$router.push({
              name:'login'
            })
        }
      }else if(i==3){//个人中心
        if(localStorage.getItem("phone")){
              this.$router.push({
              name:l.name
            })
        }else{
            this.$router.push({
              name:'login'
            })
        }
      }else{
          this.$router.push({
            name:l.name
          })
      }
    }
  }
};
</script>


<style lang="scss" scoped>
footer {
  width: 100%;
  height: 60px;
  position: fixed;
  left: 0;
  bottom: 0;
  background: #f00;
  display: flex !important;
  z-index: 100;
  border-top: 0.5px solid #b9b9b9;
  display: flex;
  align-items: center;
  div {
    flex: 1;
    height: 45px;

    a {
      display: block;
      width: 100%;
      height: 100%;
      display: flex;
      flex-direction: column;
      box-sizing: border-box;
      padding: 3px 0;
      text-align: center;
      font-family: "微软雅黑";
      color: #fff;
      position: relative;
      i {
        width: 100%;
        height: 20px;
        line-height: 20px;
        font-size: 22px !important;
        margin-bottom: 5px;
      }
      span {
        width: 100%;
        height: 19px;
        line-height: 19px;
        font-size: 14px;
      }
    }
    .nav-active,
    .router-link-exact-active,
    .router-link-active {
      color: #333;
      border-color: #333;
    }
  }
}
</style>